//
//  main.m
//  10-Foundation-NSObject
//
//  Created by Jason on 15/10/11.
//  Copyright © 2015年 Jason. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "Person.h"

// performSelector的使用场景
void test(SEL selector) {
    
    Person *p = [[[Person alloc] init] autorelease];
    
    [p performSelector:selector];
}

int main(int argc, const char * argv[]) {
    @autoreleasepool {
        
        Person *p = [[[Person alloc] init] autorelease];
        
        // 对象p是否有遵守某个协议
        // bool result = [p conformsToProtocol:@protocol(NSObject)];
        // NSLog(@"%d", result);
        
        // 判断对象p有无实现study方法
//        [p respondsToSelector:@selector(study)];
        
        
        if ([p respondsToSelector:@selector(study)] == YES) {
            
//            [p study];
//            [p performSelector:@selector(study)]; // 同上面一样
            
//            [p test:@"123123"];
            // 有两个参数 该方法是无法实现
            [p performSelector:@selector(test:) withObject:@"mike"];
            
            
            // 3秒后执行一个方法
//            [p performSelector:@selector(selector) withObject: id afterDelay:3];
            
            
        } else {
            NSLog(@"p没有实现study方法");
        }
        
        
        
        /*
        Person *p = [[[Person alloc] init] autorelease];
        
        // 返回P对象的类对象
//        Class c = [Person class];
        
        // isKindOfClass:判断对象p是否为某种类型或者其子类
//        BOOL result = [p isKindOfClass:[Person class]];
        
        // 是否是NSObject子类
        BOOL result = [p isKindOfClass:[NSObject class]];
        
        NSLog(@"%d",result);
        
        // isMemberOfClass: 判断p是否为某种类型 但是不包括子类
        [p isMemberOfClass:[Person class]];
         
         */
        
    }
    return 0;
}
